package com.yfp.device.api.factory;

import com.yfp.common.core.domain.R;
import com.yfp.device.api.RemoteDeviceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDeviceService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteDeviceFallbackFactory.class);

    @Override
    public RemoteDeviceService create(Throwable throwable) {
        log.error("device服务调用失败:{}", throwable.getMessage());
        return new RemoteDeviceService() {

            @Override
            public R<Void> sendWeiXin() {
                return R.fail("企业微信发送报警信息失败:" + throwable.getMessage());
            }

        };
    }
}